//
//  PickViewController.m
//  Hai
//
//  Created by admin on 16/3/8.
//  Copyright © 2016年 wangzijian. All rights reserved.
//

#import "HeatPickViewController.h"
@interface HeatPickViewController ()
@end

@implementation HeatPickViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
    self.pickview.dataSource =self;
    self.pickview.delegate =self;
    [self initPickerData];
    [self pickerView:self.pickview didSelectRow:0 inComponent:0 ];
    [self pickerView:self.pickview didSelectRow:0 inComponent:1 ];
}
//初始化PickerView使用的数据源
-(void)initPickerData{
      [self loaddata];
}

#pragma mark-  加载性别选择数据
- (void)loaddata{
    _arrayData =[NSArray arrayWithObjects: @"35.0℃", @"35.1℃", @"35.2℃", @"35.3℃", @"35.4℃", @"35.5℃", @"35.6℃", @"35.7℃", @"35.8℃", @"35.9℃", @"36.0℃", @"36.1℃", @"36.2℃",@"36.3℃",@"36.4℃",@"36.5℃",@"36.6℃",@"36.7",@"36.8℃",@"36.9℃",@"37.0℃",@"37.1℃",@"37.2℃",@"37.3℃",@"37.4℃",@"37.5℃",@"37.6℃",@"37.7℃",@"37.8℃",@"37.9℃",@"38.0℃",@"38.1℃",@"38.2℃",@"38.3℃",@"38.4℃",@"38.5℃",@"38.6℃",@"38.7℃",@"38.8℃",@"38.9℃",@"39.0℃",@"39.1℃",@"39.2℃",@"39.3℃",@"39.4℃",@"39.5℃",@"39.6℃",@"39.7℃",@"39.8℃",@"39.9℃",@"40.0℃",@"40.1℃",@"40.2℃",@"40.3℃",@"40.4℃",@"40.5℃",@"40.6℃",@"40.7℃",@"40.8℃",@"40.9℃",@"41.0℃",@"41.1℃",@"41.2℃",@"41.3℃",@"41.4℃",@"41.5℃",@"41.6℃",@"41.7℃",@"41.8℃",@"41.9℃",@"42.0℃",@"42.1℃",@"42.2℃",@"42.3℃",@"42.4℃",@"42.5℃",@"42.6℃",@"42.7℃",@"42.8℃",@"42.9℃",@"43.0℃",nil];
}



#pragma mark  --- delegate 视图委托 ---
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView{
        return 1;
}


- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component{
        return [_arrayData count];
    
}
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component{
    return 38;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{

        _heatData =_arrayData[row];
        _heatDataIndex = [NSString stringWithFormat:@"%f",(row*0.1)+35];
    
}
-(NSString *)pickerView:(UIPickerView *)pickerView
            titleForRow:(NSInteger)row forComponent:(NSInteger)componen{
 
        return [_arrayData objectAtIndex:row];

}

- (IBAction)tapcancel:(id)sender {
//    _dayData=@"1天";
//    _dayDataIndex=@"1";
//    if (([self.dayDataDelegate respondsToSelector:@selector(sendDayData:dayDataIndex:)])) {
//        [self.dayDataDelegate sendDayData:_dayData dayDataIndex:_dayDataIndex];
//    }
    [self removeview];
}
- (IBAction)tapconfirm:(id)sender {
   if (([self.heatDataDelegate respondsToSelector:@selector(sendHeatData:heatDataIndex:)])) {
        [self.heatDataDelegate sendHeatData:_heatData heatDataIndex:_heatDataIndex];
    }
    [self removeview];
}
- (IBAction)tapbackground:(id)sender {
//    if (([self.dayDataDelegate respondsToSelector:@selector(sendDayData:dayDataIndex:)])) {
//        [self.dayDataDelegate sendDayData:_dayData dayDataIndex:_dayDataIndex];
//    }
    [self removeview];
}
- (void)removeview{
    [self.view removeFromSuperview];
    [self removeFromParentViewController];
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
